using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using THSLib;
using THSERP.BusinessEntities;

namespace THSERP.BaseProvider
{
    public partial class guiInventoryStatus : THSERPScreen
    {
        public DataTable StatusTable;

        public guiInventoryStatus()
        {
            InitializeComponent();

            StatusTable = new DataTable();
            StatusTable.Columns.Add("StyleNumber");
            StatusTable.Columns.Add("Description");
            StatusTable.Columns.Add("Barcode");
            StatusTable.Columns.Add("Attribute");
            StatusTable.Columns.Add("Status");

            fld_dgcInventoryStatus.DataSource = StatusTable;
        }

        private void fld_btnContinue_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void fld_btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        public void AddNewRow(BusinessObject obj, String tableName, TransactionUtil.InventoryStatus status)
        {
            
            ICProductsController objProductsController = new ICProductsController();
            int iProductID = Convert.ToInt32(THSDbUtil.GetPropertyValue(obj, "FK_ICProductID"));
            ICProductsInfo objProductsInfo = (ICProductsInfo)objProductsController.GetObjectByID(iProductID);
            DataRow row = StatusTable.NewRow();
            row["StyleNumber"] = objProductsInfo.ICProductNo;
            row["Description"] = objProductsInfo.ICProductDesc;
            row["Barcode"] = THSDbUtil.GetPropertyValue(obj, tableName.Substring(0, tableName.Length - 1) + "ProductSerialNo").ToString();
            row["Attribute"] = THSDbUtil.GetPropertyValue(obj, tableName.Substring(0, tableName.Length - 1) + "ProductAttribute").ToString();
            row["Status"] = TransactionUtil.GetInventoryStatusMessage(status);
            StatusTable.Rows.Add(row);
        }
    }
}